// https://www.luogu.com.cn/problem/B2064

#include <stdio.h>


int main() {
    int n;
    int arr[9][9];
    scanf("%d", &n);
    int left = 0, right = n-1;
    int top = 0, bottom = n-1;
    int cnt = 1, row = 0, col = 0;
    while (cnt <= n*n) {
        while (cnt <= n*n && row >= top && row <= bottom && col >= left && col <= right) {
            arr[row][col] = cnt;
            cnt++;
            col++;
        }
        top++; col = right; row = top;

        while (cnt <= n*n && row >= top && row <= bottom && col >= left && col <= right) {
            arr[row][col] = cnt;
            cnt++;
            row++;
        }
        right--; row = bottom; col = right;

        while (cnt <= n*n && row >= top && row <= bottom && col >= left && col <= right) {
            arr[row][col] = cnt;
            cnt++;
            col--;
        }
        bottom--; col = left; row = bottom;

        while (cnt <= n*n && row >= top && row <= bottom && col >= left && col <= right) {
            arr[row][col] = cnt;
            cnt++;
            row--;
        }
        left++;
        row = top; col = left;
    }

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            printf("%3d", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}